package com.mobile.persistent.dao;

import java.util.List;

import org.apache.commons.lang.ArrayUtils;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.mobile.persistent.base.BaseDao;
import com.mobile.persistent.entity.Purview;

@Repository
@SuppressWarnings("unchecked")
public class PurviewDao extends BaseDao<Purview, Long> {

	/**
	 * 获取操作权限码列表
	 * @param ids 一组权限的id
	 * @return
	 */
	public List<Purview> getPurviewById(Long[] ids){
		Criteria criteria = createCriteria();
		if(!ArrayUtils.isEmpty(ids)){
			criteria.add(Restrictions.in("id", ids));
		}
		return criteria.list();
	}
	
	public Purview get(Long id){
		String hql = "select p from Purview p where p.id=?";
		return (Purview)createQuery(hql, id).uniqueResult();
	}
}
